At 19:07 +0200 on 9/11/98, Bob Kruger wrote:
>
> I do have two questions. Firstly, I have one table that is updated from a
> text file. This table also has a serial field that is incremented with
> each new record. Is there a way to use the copy command to have that field
> automatically updated - e.g. copy table_one from '/data/files/input.txt'
> using delimiters '|' ?
>
> So far, I can get this text file to import just fine when using a table
> without a serial field, but as of yet not had any luck in importing it into
> a table that has a serial field.
Assuming the serial field is defined as a NOT NULL DEFAULT nextval( 'seq'
), the simplest way is to put nulls for that field in the text file. That
is, suppose it is the third field in your table, you write
data for field1|data for field 2|\N|data for field4...
The \N (capital N) stands for null, and will cause Postgres to use the
default value for that field.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma